<?php
/**
 * 空间控制器
 * 
 * @category QuickBug
 * @copyright http://www.vquickbug.com
 */
class MyController extends BaseController
{
	/**
	 * 模型
	 *
	 * @var unknown_type
	 */
	private $model;
	
	/**
	 * 自动运行
	 */
	public function init(){
		parent::init();
		$this->model = new Model_My();
		
	}
	
	public function indexAction(){
		$this->view->controller = $this->controller;
	}
	
	public function carAction(){
		$this->view->controller = $this->controller;
	}
	
	public function dinnerAction(){
		$this->view->controller = $this->controller;
	}
	
	public function documentAction(){
		$this->view->controller = $this->controller;
	}
	
	public function carlistAction(){
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
		$offset = ($page-1)*$rows;
		
		$date1 = (isset($_POST['date1'])&&!empty($_POST['date1'])) ? $_POST['date1'] : date('Y-m').'-01';
		$date2 = (isset($_POST['date2'])&&!empty($_POST['date1'])) ? $_POST['date2'] : date('Y-m-d');
		
		$num = (isset($_POST['num'])&&!empty($_POST['num'])) ? mysql_real_escape_string($_POST['num']) : '';
		if($num){
			$num_arr = explode('TRA', $num, 2);
			$id = intval($num_arr[1]);
		}
		else{
			$id=0;
		}
		
		$param = array(
			'id'=>$id,
			'uid'=>$this->userid,
			'date1'=>$date1,
			'date2'=>$date2,
			'offset'=>$offset,
			'rows'=>$rows,
		);
		$model = new Model_Order_Car();
		$result = $model->listOrderCar($param);
		
		echo json_encode($result);
		
		QP_Layout::stop();
		$this->setViewAutoRender(false);
	}
}